import { Component, OnInit } from "@angular/core";
@Component({
  selector: 'key-data-card',
  templateUrl: './key-data.component.html'
})

export class KeyDataComponent implements OnInit {
  fontStatus: string;
  profilesData = [];
  provinceDetailData = [];
  extraDetailData = [];
  constructor() {
    //
  }
  ngOnInit() {
    this.getProfilesData();
    this.getProvinceDetailData();
    this.getExtraDetailData();
  }

  getProfilesData() {
    let data1 = [{
      indexName: "资产总额",
      indexCode: "any",
      summation: 744500000000,
      growth: 0.0063
    }, {
      indexName: "营业收入",
      indexCode: "any",
      summation: 494600000000,
      growth: 0.0063
    }, {
      indexName: "利润总额",
      indexCode: "any",
      summation: 18030000000,
      growth: -0.0063
    }, {
      indexName: "售电量",
      indexCode: "any",
      summation: 890200000000,
      growth: -0.0063
    }];
    for (let i = 0; i < data1.length; i++) {
      this.profilesData.push({
        indexName: data1[i].indexName,
        indexCode: data1[i].indexCode,
        summation: data1[i].summation / 100000000,
        growth: Math.abs(data1[i].growth) * 100,
        growthStatus: data1[i].growth < 0 ? 'down' : 'up'
      });
    }
    console.log(this.profilesData);
  }
  getProvinceDetailData() {
    let data2 = [{
      name: "云南",
      targetValue: 6500000000,
      actualValue: 8058000000,
      warningLevel: "0"
    }, {
      name: "贵州",
      targetValue: 6500000000,
      actualValue: 7058000000,
      warningLevel: "2"
    }, {
      name: "广西",
      targetValue: 6500000000,
      actualValue: 6058000000,
      warningLevel: "2"
    }, {
      name: "海南",
      targetValue: 6500000000,
      actualValue: 5058000000,
      warningLevel: "0"
    }, {
      name: "广东",
      targetValue: 6500000000,
      actualValue: 4058000000,
      warningLevel: "1"
    }, {
      name: "广州",
      targetValue: 6500000000,
      actualValue: 3058000000,
      warningLevel: "0"
    }, {
      name: "深圳",
      targetValue: 6500000000,
      actualValue: 1058000000,
      warningLevel: "1"
    }];
    for (let i = 0; i < data2.length; i++) {
      switch (data2[i].warningLevel) {
        case "0":
          this.fontStatus = "status-1";
          break;
        case "1":
          this.fontStatus = "status-2";
          break;
        case "2":
          this.fontStatus = "status-3";
          break;
      }
      this.provinceDetailData.push({
        name: data2[i].name,
        targetValue: data2[i].targetValue / 100000000,
        actualValue: data2[i].actualValue / 100000000,
        fontStatus: this.fontStatus
      });
    }
    console.log(this.provinceDetailData);
  }
  getExtraDetailData() {
    let data3 = [{
      name: "业务利润",
      targetValue: 6500000000,
      actualValue: 3058000000,
      warningLevel: "1"
    }, {
      name: "涉及竞争",
      targetValue: 6500000000,
      actualValue: 3058000000,
      warningLevel: "2"
    }, {
      name: "涉及竞争",
      targetValue: 6500000000,
      actualValue: 3058000000,
      warningLevel: "0"
    }];
    for (let i = 0; i < data3.length; i++) {
      switch (data3[i].warningLevel) {
        case "0":
          this.fontStatus = "status-1";
          break;
        case "1":
          this.fontStatus = "status-2";
          break;
        case "2":
          this.fontStatus = "status-3";
          break;
      }
      this.extraDetailData.push({
        name: data3[i].name,
        targetValue: data3[i].targetValue / 100000000,
        actualValue: data3[i].actualValue / 100000000,
        fontStatus: this.fontStatus
      });
    }
    console.log(this.extraDetailData);
  }
}
